package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 陈辉
 * @data 2023 10:45
 */
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {

    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult channels(){
        return wmChannelService.findAll();
    }

    /**
     * 新增频道
     * @Params:
     * @Return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmChannel wmChannel){
        return wmChannelService.saveChannel(wmChannel);
    }

    /**
     * 删除频道
     * @Params:
     * @Return
     */
    @GetMapping("del/{id}")
    public ResponseResult del(@PathVariable Integer id){
        return wmChannelService.delChannel(id);
    }

    /**
     * 频道分页
     * @Params:
     * @Return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmChannelDto dto){
        return wmChannelService.channelList(dto);
    }

    /**
     * 修改频道
     * @Params:
     * @Return
     */
    @PostMapping("/update")
    private ResponseResult update(@RequestBody WmChannel wmChannel){
        return wmChannelService.updateChannel(wmChannel);
    }
}
